﻿package ua.mihaylenko.cardsplugin.common{

	public dynamic class FlashVars {
		private var _smcStage;
		public static var _cInstance:FlashVars
		
		public function FlashVars(){
			
		}
		
		public static function getInstance():FlashVars{
			if(_cInstance == null) _cInstance = new FlashVars();
			return _cInstance;
		}
		public function initFlashVars(mcStage){
			_smcStage = mcStage;
		}
		public function deleteInstance(){
			//It is very important that our singlton classes have deleteInstance functions 
			//so that we can clear them for garbage collection
			if (_cInstance){
				_cInstance = null;
			}
		}
		public function getData(sVariableName):String{
				if(_smcStage.loaderInfo.parameters[sVariableName] != null){
					_smcStage[sVariableName]=_smcStage.loaderInfo.parameters[sVariableName];
				}
				return (_smcStage[sVariableName]);
		}
		public function setData(sVariableName:String, oValue){
			_smcStage[sVariableName] = oValue;
		}
		
		// check whether it's in single template mode
		public function isSingleTemplate():Boolean{
		    var param:String = this.getData('singletemplate');
			return (param == 'true');
		}
		
	}
}